/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2011 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _SURFACEOPENGLES_H_
#define _SURFACEOPENGLES_H_

#include "RenderMethodOpenGLES.h"

#include "YGSurface.h"
#include "SourcesOpenGLES.h"

namespace YoghurtGum
{

	class SurfaceOpenGLES : public Surface
	{
	
	public:
	
		SurfaceOpenGLES(TextureOpenGLES* a_Tex, int a_Width, int a_Height);
		~SurfaceOpenGLES();

		void Lock();

		void Fill(Color a_Color);
		void Resize(int a_Width, int a_Height);

		bool DumpTo(Surface* a_Target);
		bool CopyTo(Surface* a_Target, int a_X, int a_Y);

		void Plot(int a_PosX, int a_PosY, Color a_Color);
		void Line(float a_FromX, float a_FromY, float a_ToX, float a_ToY, Color a_Color);
		void Square(int a_StartX, int a_StartY, int a_EndX, int a_EndY, Color a_Color);

		YGC* GetBuffer();
		void SetBuffer(YGC* a_Buffer);

		void Unlock();

		bool Draw(int a_X, int a_Y);

	private:

		void Init(int a_Width, int a_Height);

		GLfixed m_FixedWidth, m_FixedHeight;
		GLsizei m_TextureWidth, m_TextureHeight;
		GLfixed m_Vertices[18], m_UVs[12];
		YGC* m_Pixels;
		TextureOpenGLES* m_Texture;

	}; // class SurfaceOpenGLES

}; // namespace YoghurtGum
	
#endif